package rpg.visual.menu;

import java.awt.Graphics2D;
import java.util.ArrayList;

import pgui.PVisual;
import pgui.visual.PComponent;
import rpg.action.Skill;
import rpg.visual.menu.skill.VisualMenuSkill;

public class VisualMenuSkills extends PComponent {
	private static final int MENU_WIDTH = 36;
	private static final int MENU_DISTANCE = 4;

	private ArrayList<VisualMenuSkill> skills = new ArrayList<VisualMenuSkill>();

	public VisualMenuSkills(PVisual visual) {
		super(visual);
		this.setRelativeHeight(100);

		for (int i = 1; i < 10; i++) {
			skills.add(new VisualMenuSkill(visual));
			this.addChild(this.getSkills().get(i - 1));

			skills.get(i - 1).setX((i - 1) * (MENU_WIDTH + MENU_DISTANCE));
			skills.get(i - 1).setY(2);
		}

		this.setWidth(this.getSkills().size() * (MENU_WIDTH + MENU_DISTANCE));
		this.setX(-this.getWidth());
	}

	// Skill
	public VisualMenuSkill get(int index) {
		return this.getSkills().get(index);
	}

	public void setSkill(int index, Skill skill) {
		skills.get(index).setSkill(skill);
	}

	public int count() {
		return this.getSkills().size();
	}

	public int index(VisualMenuSkill menu) {
		return this.getSkills().indexOf(menu);
	}

	// Paint Events
	@Override
	public void onPaint(Graphics2D g) {
		super.onPaint(g);

		// g.setColor(Color.darkGray);
		// g.fillRect(0, 0, this.getLastWidth(), this.getLastHeight());
	}

	// Get & Set
	protected ArrayList<VisualMenuSkill> getSkills() {
		return skills;
	}

	protected void setSkills(ArrayList<VisualMenuSkill> skills) {
		this.skills = skills;
	}
}
